#include<iostream>
using namespace std;
const int MAX_NODE = 100001;
const int MAX_EDGE = 1000001;

struct Edge{
	int to,next;
}edge[MAX_EDGE];

int head[MAX_NODE],n,e,num_edge;
bool vis[MAX_NODE];

void add_Edge(int i,int j){
	edge[++num_edge].next = head[i];
	edge[num_edge].to = j;
	head[i] = num_edge; 
}

void dfs(int k){
	vis[k] = true;
	int next = head[k];
	while(next != 0){
		if(vis[edge[next].to] == false){
			dfs(edge[next].to);
		}
		next = edge[next].next;
	}
	
}

int main(){
	cin>>n>>e;
	for(int i=0;i<e;i++){
		int s,j;
		cin>>s>>j;
		add_Edge(s,j);
		add_Edge(j,s);
	}
	int sum = 0;
	for(int i=1;i<=n;i++){
		if(!vis[i]){
			sum++;
			dfs(i);
		}
		
	}
	cout<<sum<<endl;
	
	return 0;
}
